/***************************************************************************
 *                                                                         *
 *   This is FotoKinect.  It's important to note that we used many ideas   *
 *	 and code from Enrico Ros's OSS Fotowall. This program was created for *
 *   a final project for CS032 at Brown University by Gianna Badiali,	   *
 *   Gabriel Fernandez, Sam Swarr, and Kelsey Tripp.					   *
 *																	       *
 ***************************************************************************/


/*************************************
There are no important parts in this file that 
were modified for the project.
**************************************/

#include <QApplication>
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include <QSettings>
#include <QStyle>
#include <QtPlugin>
#include <qlabel.h>
#include "MainWindow.h"
#include "RenderOpts.h"


#if defined(STATIC_LINK)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qsvg)
Q_IMPORT_PLUGIN(qtiff)
#endif

// init RenderOpts defaults
bool RenderOpts::LastMirrorEnabled = true;
bool RenderOpts::ARGBWindow = false;
bool RenderOpts::HQRendering = false;
bool RenderOpts::FirstRun = false;
bool RenderOpts::OxygenStyleQuirks = false;
bool RenderOpts::DisableVideoProvider = false;
QColor RenderOpts::hiColor;

int main( int argc, char ** args )
{
#if !defined(Q_OS_MAC) // raster on OSX == b0rken
    // use the Raster GraphicsSystem as default on 4.5+
#if QT_VERSION >= 0x040500
    QApplication::setGraphicsSystem("raster");
#endif
#endif

    QApplication app(argc, args);
    app.setApplicationName("FotoKINECT");
    app.setApplicationVersion("1");
    app.setOrganizationName("OSS started by Enrico Ros with contribution by Gianna Badiali, Gabriel Fernandez, Samuel Swarr, Kelsey Tripp");
    RenderOpts::OxygenStyleQuirks = app.style()->objectName() == QLatin1String("oxygen");

    QSettings s;
    RenderOpts::FirstRun = s.value("fotowall/firstTime", true).toBool();
    RenderOpts::hiColor = app.palette().color(QPalette::Highlight);
    s.setValue("fotowall/firstTime", false);

    MainWindow mw;

    mw.showMaximized();

    app.processEvents();
    QStringList images;
    for (int i = 1; i < argc; i++) {
        QString filePath = args[i];
        if (filePath.endsWith(".fotowall", Qt::CaseInsensitive))
            mw.loadXml(filePath);
        else
            images << filePath;
    }
    mw.loadImages(images);

    return app.exec();
}
